package br.usp.ime.origami.solver;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class SolverFrameBuilder {

    public JFrame build(List<Part> parts, int L) {
        SolverCanvas canvas = new SolverCanvas(parts, L);
        JFrame frame = new JFrame("Origami solver");
        frame.setLayout(new BorderLayout());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel buttons = new JPanel(new GridLayout(1, parts.size()));
        for (Part part : parts) {
            buttons.add(part.getButtonFor(canvas));
        }
        frame.add(buttons, BorderLayout.NORTH);
        frame.add(canvas);
        return frame;
    }

}
